package com.secsbrain.cmdb.web.controller;

import java.util.Date;

import com.secsbrain.cmdb.biz.IIdclevelService;
import com.secsbrain.sso.core.SsoHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.baomidou.mybatisplus.plugins.Page;
import com.secsbrain.common.ResponseResult;
import com.secsbrain.cmdb.dal.model.Idclevel;

/**
 * 机房等级控制层
 * @author zhaoyi
 *
 */
@RestController
@RequestMapping("api/idclevel")
public class IdclevelController{
	
    @Autowired
    IIdclevelService idclevelService;
    
    /**
     * 功能描述: <br>
     * 查询列表
     *
     * @param params
     * @return
     */
    @RequestMapping(value = "/list", method = RequestMethod.GET)
    public ResponseResult<?> queryList(Idclevel params) {
    	Page<Idclevel> page=new Page<Idclevel>(0, 10);
    	Page<Idclevel> result=idclevelService.selectPage(page, params);
    	return new ResponseResult(result);
    }
    
    /**
     * 功能描述: <br>
     * 新增
     *
     * @param idclevel
     * @return
     */
    @RequestMapping(value = "/insert", method = RequestMethod.POST)
    public ResponseResult<?> insert(@RequestBody Idclevel idclevel) {
    	idclevel.setCreateTime(new Date());
    	idclevel.setCreator(SsoHelper.currentUser().getNickname());
    	idclevelService.insertSelective(idclevel);
    	return new ResponseResult();
    }
    
    /**
     * 功能描述: <br>
     * 更新
     *
     * @param idclevel
     * @return
     */
    @RequestMapping(value = "/update", method = RequestMethod.PUT)
    public ResponseResult<?> update(@RequestBody Idclevel idclevel) {
    	idclevel.setUpdateTime(new Date());
    	idclevel.setUpdator(SsoHelper.currentUser().getNickname());
    	idclevelService.updateSelectiveById(idclevel);
    	return new ResponseResult();
    }
    
    /**
     * 功能描述: <br>
     * 删除
     *
     * @param idclevel
     * @return
     */
    @RequestMapping(value = "/delete", method = RequestMethod.DELETE)
    public ResponseResult<?> delete(@RequestBody Idclevel idclevel) {
    	idclevelService.deleteById(idclevel.getId());
    	return new ResponseResult();
    }
    
}
